from sqlalchemy import Column, Integer, String, DateTime, ForeignKey, Enum, Text, Date
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from app.core.database import Base
import enum

class StageType(str, enum.Enum):
    PROPERTY = "property"
    START = "start"
    INSPECTION = "inspection"
    ACCEPTANCE = "acceptance"
    SETTLEMENT = "settlement"

class ProjectStage(Base):
    __tablename__ = "project_stages"
    
    id = Column(Integer, primary_key=True, index=True)
    project_id = Column(Integer, ForeignKey("projects.id"), nullable=False, index=True)
    stage_type = Column(Enum(StageType), nullable=False, index=True)
    stage_date = Column(Date, nullable=False)
    operator = Column(String(50), nullable=True)
    content = Column(Text, nullable=True)
    status = Column(String(20), nullable=True)
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    
    project = relationship("Project", back_populates="stages")

